// 配置路由模块
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { HomeComponent } from './components/home/home.component';
import { NewsComponent } from './components/news/news.component';
import { ProductsComponent } from './components/products/products.component';
import { NewscontentComponent } from './components/newscontent/newscontent.component';
import { ProductcontentComponent } from './components/productcontent/productcontent.component';

const routes: Routes = [
  {
    path: 'home', component: HomeComponent
  },
  {
    path: 'news', component: NewsComponent
  },
  {
    path: 'product', component: ProductsComponent
  },
  // {  get传值
  //   path: 'newscontent', cormponent: NewscontentComponent
  // },
  {
    // 动态路由
    path: 'newscontent/:aid', component: NewscontentComponent
  },
  {
    // 匹配不到路由的时候加载的组件 或者跳转的路由
    path: '**',    //任意的路由
    // component: HomeComponent
    redirectTo: 'home'
  },
  {
    // 动态路由
    path: 'productcontent/:pid', component: ProductcontentComponent
  },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
